<?php

use Illuminate\Database\Seeder;

class SchoolsTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $schools = config('admin.location.school');
        $provinces = config('admin.location.province');
        foreach ($provinces as $province=> $item) {
            $cities = config('admin.location.city.'.$province);
            foreach ($cities as $city=>$v) {
                foreach ($schools[$city] as $school) {
                    try {
                        $s = new \App\Models\School();
                        $s->name = $school[2];
                        $s->city = $v;
                        $s->province = $province;
                        $s->save();
                    } catch (Exception $exception) {
                        echo $exception->getMessage();
                    }
                }
            }
        }
    }
}
